import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UnitMeasureVO, UnitMeasureForm, UnitMeasureQuery } from '@/api/base/material/unitMeasure/types';

/**
 * 查询计量单位列表
 * @param query
 * @returns {*}
 */

export const listUnitMeasure = (query?: UnitMeasureQuery): AxiosPromise<UnitMeasureVO[]> => {
  return request({
    url: '/base/material/unitMeasure/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取计量单位列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: UnitMeasureForm): AxiosPromise<UnitMeasureForm[]> => {
  return request({
    url: '/base/material/unitMeasure/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询计量单位详细
 * @param id
 */
export const getUnitMeasure = (id: string | number): AxiosPromise<UnitMeasureVO> => {
  return request({
    url: '/base/material/unitMeasure/' + id,
    method: 'get'
  });
};

/**
 * 新增计量单位
 * @param data
 */
export const addUnitMeasure = (data: UnitMeasureForm) => {
  return request({
    url: '/base/material/unitMeasure',
    method: 'post',
    data: data
  });
};

/**
 * 修改计量单位
 * @param data
 */
export const updateUnitMeasure = (data: UnitMeasureForm) => {
  return request({
    url: '/base/material/unitMeasure',
    method: 'put',
    data: data
  });
};

/**
 * 删除计量单位
 * @param id
 */
export const delUnitMeasure = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/material/unitMeasure/' + id,
    method: 'delete'
  });
};

export default {
  queryList
};
